import React from 'react'
import {HashRouter, Redirect, Route, Switch} from 'react-router-dom'
import Login from '../views/login/Login'
import NewsSandBox from '../views/sandbox/NewsSandBox'

export default function IndexRouter() {
  return (
    <HashRouter>
        <Switch>
          {/* 一级路由 */}
            <Route path="/login" component={Login}></Route>
            {/* <Route path="/" component={NewsSandBox}></Route> */}
            <Route path="/" render={()=>
            // 重定项到login 注意：此处浏览器都是围绕着有token的，控制台localStorage.setItem('token')
                localStorage.getItem('token') ? <NewsSandBox></NewsSandBox> : <Redirect to='/login'/>
            }>
            </Route>
        </Switch>
    </HashRouter>
  )
}
